/****** Object:  Stored Procedure [dbo].spPhieuNhapGet Script Date: 6/12/2012 ******/
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = object_id(N'[dbo].[spPhieuNhapGetForPrinting]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
	DROP PROCEDURE [dbo].[spPhieuNhapGetForPrinting]
GO

/******************************************************************************
**		Change History
*******************************************************************************
**		Date:		Author:					Description:
**		--------	--------				-----------------------------------
**		24/06/2012	SongTM					Innit created
*******************************************************************************/

CREATE PROCEDURE [dbo].[spPhieuNhapGetForPrinting]
(
	@SoPN nvarchar(14)
)
WITH ENCRYPTION
AS

SET NOCOUNT ON

SELECT 
	*
FROM 
	[tbl_PhieuNhap]	Inner join tbl_ChiTietPhieuNhap ON [tbl_PhieuNhap].SoPN = [tbl_ChiTietPhieuNhap].SoPN
	INNER JOIN [tbl_LuuKho] ON [tbl_ChiTietPhieuNhap].MaLuuKho = tbl_LuuKho.MaLuuKho
	INNER JOIN tbl_NhaCungCap ON [tbl_NhaCungCap].MaNCC = [tbl_PhieuNhap].MaNCC
	INNER JOIN tbl_KhoHang ON [tbl_KhoHang].MaKho = [tbl_PhieuNhap].Makho
	INNER JOIN tbl_SanPham ON [tbl_Sanpham].MaThuoc = [tbl_LuuKho].Mathuoc
	INNER JOIN tbl_DonViTinh ON [tbl_DonViTinh].MaDonVi = [tbl_SanPham].MaDonVi
WHERE
	[tbl_PhieuNhap].[SoPN] = @SoPN
	
Select * from tbl_Congty
GO

--GRANT EXECUTE ON [dbo].[spPhieuNhapGet] TO [sa]
--GO